<%@page import="java.sql.*" %>
<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<!DOCTYPE html>
<html>
<head>
<title>整表数据</title>
<%! ResultSet rs; //数据库查询结果 %>
<%
        String dbName = "dmeo";
        String userName = "root";
        String userPassword= "123456";
        String url = "jdbc:mysql://localhost/"+dbName+"?user="+userName+"&password="+userPassword;
        Class.forName("com.mysql.cj.jdbc.Driver");
        Connection conn = DriverManager.getConnection(url);
        Statement statement = conn.createStatement();
        String sql = "select * from student";
        rs =statement.executeQuery(sql);
        %>
</head>
<body>
<table border="1">
<th colspan="4" style="font-size: x-large;alignment: center">学生信息表</th>
<tr style="text-align: center">
<td>学号</td>
<td>姓名</td>
<td>出生日期</td>
<td>所在班级</td>
</tr>
<%-- 循环展示数据--%>
<% while (rs.next()){%>
<tr style="text-align: center">
<td><%=rs.getString(1)%></td>
<td><%=rs.getString(2)%></td>
<td><%=rs.getString("birthday")%></td>
<td><%=rs.getString("sthclass")%></td>
</tr>
<% } %>
<%
        rs.close();
        statement.cancel();
        conn.close();
        %>
</table>


</body>
</html>